package me.zhengjie.modules.utils;

import cn.hutool.http.Header;
import cn.hutool.http.HttpRequest;
import cn.hutool.json.JSONObject;
import cn.hutool.json.JSONUtil;

import java.util.HashMap;

public class CheckOnlineUtil {

    public static boolean check(String ip,String port ,String steamId,String password ){
        HashMap<String, Object> paramMap = new HashMap<>();
        paramMap.put("server_url", ip);
        paramMap.put("port",port);
        paramMap.put("steamid", steamId);
        paramMap.put("password", password);
        String result = HttpRequest.post("http://117.72.109.6:5000/getPlayerStatus")
                .header(Header.USER_AGENT, "Hutool http")//头信息，多个头信息多次调用此方法即可
                .form(paramMap)//表单内容
                .timeout(20000)//超时，毫秒
                .execute().body();
        JSONObject entries = JSONUtil.parseObj(result);
        return entries.getBool("status");
    }
}
